#coding: utf-8

from django.http import HttpResponse
from django.shortcuts import render
import gpio

# Create your models here.
def index(request):
	return render(request, 'index.html')


def gpioset(request):
	gpiovalue = request.GET['a']
	gpionumber = gpiovalue.split('#')[0]
	gpiostate = gpiovalue.split('#')[1]

	gpio.gpiosetup(gpionumber, '0')


	if gpiostate == 'k':
		gpio.gpiooutput(gpionumber, 1)
	elif gpiostate == 'g':
		gpio.gpiooutput(gpionumber, 0)

	return HttpResponse(a)